const WXAPI = require('../../wxapi/main')
const CONFIG = require('../../config.js')

var t = require("../../nitro.js"), e = (require("../../configs.js"), getApp());

Page({
    data: {
        isIpx: e.globalData.isIpx,
        stores: [],
        xitems: []
    },
    onLoad: function(t) {
        this.setData({
            options: t
        });
    },
    onReady: function() {},

        // 分享
        onShareAppMessage: function() {
            return {
                title: "秒秒哆儿童摄影",
            };
        },
      //用户点击右上角分享朋友圈
	onShareTimeline: function () {
            return {
                title: "秒秒哆儿童摄影",
            }
        },
    
    onShow: function() {

        let that = this;
        // var a = this, o = t.getStore();

        // wx.setNavigationBarTitle({
        //     title: "" + o.name
        // }),
        
        // delete e.globalData.categories, delete e.globalData.items, delete e.globalData.themeGroups;

   
        WXAPI.fetchShops().then(function(res) {

            if (res.code == 0) {
              console.log(res);
              
              
              that.setData({
                xitems: res.data,
              });

            }
            console.log(that.data.xitems);
          

          })

        
        // WXAPI.goodsCategory().then(function(res) {
        //     let categories = [];
        //     if (res.code == 0) {
        //       categories = categories.concat(res.data);
        //       console.log(categories);
              
              
        //       that.setData({
        //         loaded: !0,
        //         items: categories,
        //       });

        //     }
          

        //   })


      
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    initStores: function() {},
    // 点击跳转
    itemTapHandler: function(a) {
 

        wx.setStorageSync("jxzmd",a.currentTarget.dataset.id)

        var r = "/pages/artworks/artworks?dianpu=" + a.currentTarget.dataset.id;
        wx.navigateTo({
            url: r,
            success: function(t) {},
            fail: function(t) {},
            complete: function(t) {}
        });

        
        // var o = a.currentTarget.dataset.storeid,
        //     i = a.currentTarget.dataset.type,
        //     n = this.data.stores.find(function(t) {
        //     return t.id === o;
        // });

        // t.setStore(o), e.globalData.cart.store = n, e.globalData.cart.storeId = o;

        // // var r = "/pages/artworks/artworks?store_id=" + o + "&type=" + i;

        // var r = "/pages/artworks/artworks?category_id=329418&type=" + i;

        // if("wj" === i){
        //     r = "/pages/product-detail/product-detail?category_id=329417&type=" + i
        // }
     

        // wx.navigateTo({
        //     url: r,
        //     success: function(t) {},
        //     fail: function(t) {},
        //     complete: function(t) {}
        // });
    }

});